package com.luxiu.extensionlib.base

import android.app.Activity

class BaseActivityManager {
    private val allActivities: MutableList<Activity> = ArrayList()
    fun addActivity(activity: Activity?) {
        if (activity != null) {
            allActivities.add(activity)
        }
    }

    fun removeActivity(activity: Activity?) {
        if (activity != null) {
            allActivities.remove(activity)
        }
    }

    fun finishAll() {
        for (activity in allActivities) {
            activity.finish()
        }
    }

    val taskTop: Activity
        get() = allActivities[allActivities.size - 1]
}